package View;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class ChessPanel extends JPanel {
	private static final long serialVersionUID = 1L;

	private String[] s1 = { "开始", "悔棋", "认输", "和棋", "回放" };
	private JButton[] button = new JButton[s1.length];
	private JLabel[] chessBox = new JLabel[2];
	private JLabel[] player = new JLabel[2];
	String[] s2 = { "玩家1", "玩家2" };
	
	public ChessPanel() {
 
		setLayout(new BorderLayout());
		setOpaque(false);
		JPanel top = new JPanel();
		top.setOpaque(false);
		JPanel bottom = new JPanel();
		bottom.setOpaque(false);
		GridPanel gridPanel =new GridPanel();
		add(gridPanel);
		top.add(new JLabel("网络五子棋"));
		top.add(new JLabel("             逝水飞鱼 "));

		
		for (int i = 0; i < s1.length; i++) {
			button[i] = new JButton(s1[i]);
			bottom.add(button[i], BorderLayout.SOUTH);
		}
		JPanel left = new JPanel();
		left.setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		for (int i = 0; i <s2.length; i++) {
			left.setOpaque(false);						
			JLabel image = new JLabel();
			image.setIcon(new ImageIcon(getClass().getResource("../image/photo" + i + ".png")));
			player[i] = new JLabel(s2[i]);	
			gbc.gridx=0;
			gbc.gridy = i*3;
			gbc.gridwidth=0;
			gbc.insets = new Insets(10, 20, 10, 20);
			left.add(player[i], gbc);
			gbc.gridy=i*3+1;
			gbc.insets = new Insets(10, 20, 10, 20);
			
			left.add(image, gbc);
			gbc.gridy=i*3+2;
			gbc.insets = new Insets(10, 20, 10, 20);
			chessBox[i] = new JLabel("棋盒");
			//chessBox[i].setPreferredSize(new Dimension(50, 37));
			left.add(chessBox[i], gbc);
			
		}
		add(left, BorderLayout.WEST);
		add(bottom, BorderLayout.SOUTH);
		add(top, BorderLayout.NORTH);
		InfoPanel infoPanel=new InfoPanel();
		add(infoPanel,BorderLayout.EAST);
	}
	protected void paintComponent(Graphics g) {
		// TODO Auto-generated method stub
		super.paintComponent(g);
		Image img = new ImageIcon(getClass().getResource("../image/130.jpg")).getImage();
		g.drawImage(img, 0, 0, getWidth(), getHeight(), null);
	}
}
